In Next.js, a route segment refers to a part of the URL path that corresponds to a specific segment of the file system-based routing structure. Each segment in the URL maps to a folder or file in the app directory (for App Router) or pages directory (for Pages Router).
- Create a folder in the app directory. The folder name becomes the route segment.
 - Use square brackets [] to define a dynamic route segment. app/users/[id]/page.js corresponds to routes like /users/1, /users/2, etc. The id parameter can be accessed in the component.
 - Use [...slug] to define a catch-all route segment that matches all subsequent segments. app/docs/[...slug]/page.js matches /docs/a, /docs/a/b, /docs/a/b/c, etc. The slug parameter will be an array of the segments.
 - Use [[...slug]] to define an optional catch-all route segment. app/shop/[[...slug]]/page.js matches /shop, /shop/a, /shop/a/b, etc.